#include <cstdlib>
#include <iostream>
#include <string.h>
using namespace std;

class WLAN
{
      public:
             char ssid[20];
             char key[20];
      public:
             void Setssid(){
                  int n;
                  cout<<"请输入网络名称(ssid):";
                  cin.getline(ssid,n);
                  fflush(stdin);
                  };
             void Setkey(){
                  int m;
                  cout<<"请输入路由密钥(key):"; 
                  cin.getline(key,m); 
                  fflush(stdin);
             };
};

int setwindow()
{
	int i;
	for(i=0;i<=79;i++){
		cout<<"*";
		}
	cout<<"欢 迎 使 用 开 启 虚 拟 路 由 功 能 快 捷 工 具(C++版)\n";
	for(i=0;i<=79;i++){
		cout<<"*";
	}
	cout<<"软件作者:纯粹\n编写日期:2011/12/25\n主页:www.24fenxiang.com\n";
	for(i=0;i<=79;i++){
		cout<<"*";
	}
	cout<<"1.设置/修改并开启虚拟路由功能\n";
	cout<<"2.开启/关闭已设置好的WLAN热点\n";
	cout<<"3.查看网络共享设置方法\n4.退出!\n";
	for(i=0;i<=79;i++){
		cout<<"*";
}}


int xuan()
{
	int ch;
	while(ch!=4){
		cout<<"请输入相应的数字,按回车键确认:";
		cin>>ch;
		cin.ignore( 1024,'\n');
		if(ch!=1&&ch!=2&&ch!=3&&ch!=4)
			cout<<"\n输入有误,请重新输入\n";
		if(ch>=1||ch<=4)
		{   switch(ch){
			case 1:return 1; break;
			case 2:return 2; break;
			case 3:return 3; break;
			case 4:return 4; break;
			}}}}
int set()
{
    WLAN aa;
    char  dm1[1000]="netsh wlan set hostednetwork ssid=",dm2[1000]="netsh wlan set hostednetwork key=",dm3[1000]="netsh wlan set hostednetwork mode=allow";
    aa.Setssid();
    strcat(dm1,aa.ssid);
    system(dm3);
    system(dm1);
    aa.Setkey();
    strcat(dm2,aa.key);
    system(dm2);
    return 0;
}
    
int kaiqi()
{
    int n;
    cout<<"请选择你要执行的任务1.开启/2.关闭:";
    cin>>n;
    if(n==1)
       system("netsh wlan start hostednetwork");
    else if(n==2)
       system("netsh wlan stop hostednetwork"); 
    return 0;
    
}

int main(int argc, char *argv[])
{
    WLAN ss;
    int n1;
    system("cls");
    setwindow();
    n1=xuan();
    switch(n1)
    {
              case 1:set(); break;
              case 2:kaiqi(); break;
              case 3:system("start http://www.lashouwan.com/3306test.html"); break;
              case 4:exit(0); break;
              }
    system("PAUSE");
    return EXIT_SUCCESS;
}